#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
set<int>p;
int n;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int num;
		cin>>num;
		int in=p.lower_bound(num);
		if(in!=p.end())
		p.erase(in),p.insert(num);
		else
		p.inset(num);
	}
	cout<<p.size()<<endl;
	return 0;
}
